home *** CD-ROM | disk | FTP | other *** search
- /* Bars.c */
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Menus.h>
- #include <Resources.h>
- #include <Sound.h>
- #include <TextEdit.h>
- #include <ToolUtils.h>
- #include <Appearance.h>
- #include <stdlib.h>
-
- #include "Globals.h"
- #include "ResourceDefs.h"
- #include "DoScrap.h"
- #include "Miscellany.h"
- #include "Scrolling.h"
- #include "ControlUtils.h"
- #include "Dispatcher.h"
- #include "DDocData.h"
- #include "EverythingEngine.h"
- #include "EverythingDoc.h"
- #include "Bars.h"
-
-
- static EverythingEngine* GetEngine (Bars* self);
-
- static void DoUndo (Bars* self);
- static void DoCut (Bars* self);
- static void DoCopy (Bars* self);
- static void DoPaste (Bars* self);
- static void DoClear (Bars* self);
- static void DoSelectAll (Bars* self);
- static void DoShowClipboard (Bars* self);
-
-
- //----------
- Bars* NewBars ()
- {
- Bars* window;
-
- window = (Bars*)malloc (sizeof (Bars));
- Bars_Init (window);
- SetClassID (window, classBars);
-
- return window;
- }
-
- //----------
- void DeleteBars (
- Bars* window)
- {
- Bars_Free (window);
- free (window);
- }
-
- //----------
- void Bars_Create (
- AMDoc* inDoc,
- DDocData* inData)
- {
- Bars* winObj = NewBars ();
-
- if (winObj != nil) {
- Bars_Open (winObj, inDoc, inData);
- }
- }
-
- //----------
- void Bars_Init (
- Bars* self)
- {
- }
-
- //----------
- void Bars_Free (
- Bars* self)
- {
- }
-
- //----------
- EverythingEngine* GetEngine (
- Bars* self)
- {
- return (EverythingEngine*) self->super.mDoc->mEngine;
- }
-
- /*----------*/
- void Bars_Open (
- Bars* self,
- AMDoc* inDoc,
- DDocData* inData)
- {
- WindowPtr window;
- Handle wftb;
-
- self->super.mDoc = inDoc;
- self->mData = inData;
- AddResponder ((AMSignaler*) self->mData, (AMResponder*) self);
-
- window = GetNewCWindow (WIND_Bars, nil, (WindowPtr) -1L);
- if (AMEngine_GetFilename (self->super.mDoc->mEngine) [0] != 0) {
- SetWTitle (window, AMEngine_GetFilename (self->super.mDoc->mEngine));
- }
- self->super.mWindow = window;
- ((EverythingDoc*)self->super.mDoc)->mBarsPtr = window;
-
- SetWindowKind (window, 'AM');
- SetWRefCon (window, (long) self);
- SetPort (window);
- SetInfo (window);
-
- wftb = GetResource ('Wftb', WIND_Bars);
-
- CreateRootControl (window, &self->super.mRootControl);
-
- self->super.vScroll = nil;
- self->super.hScroll = nil;
-
-
- self->mBarsHandle = GetNewControl (CNTL_Bars, window);
- SetWindowItemFont (self->mBarsHandle, wftb, 1);
- SetControlValue (self->mBarsHandle, GetBars (self->mData));
- SetLayerGroupValue (self->mBarsHandle, GetBars (self->mData));
-
- self->mScrollBarsHandle = GetNewControl (CNTL_ScrollBars, window);
- EmbedControl (self->mScrollBarsHandle, self->mBarsHandle);
- SetWindowItemFont (self->mScrollBarsHandle, wftb, 2);
-
- self->mStandard4Handle = GetNewControl (CNTL_Standard4, window);
- EmbedControl (self->mStandard4Handle, self->mScrollBarsHandle);
- SetWindowItemFont (self->mStandard4Handle, wftb, 3);
- SetControlValue (self->mStandard4Handle, GetStandard2 (self->mData));
-
- self->mGraphic4Handle = GetNewControl (CNTL_Graphic4, window);
- EmbedControl (self->mGraphic4Handle, self->mScrollBarsHandle);
- SetWindowItemFont (self->mGraphic4Handle, wftb, 4);
- SetControlValue (self->mGraphic4Handle, GetGraphic2 (self->mData));
-
- self->mSliderHandle = GetNewControl (CNTL_Slider, window);
- EmbedControl (self->mSliderHandle, self->mScrollBarsHandle);
- SetWindowItemFont (self->mSliderHandle, wftb, 5);
- SetControlValue (self->mSliderHandle, GetSlider (self->mData));
-
- self->mTickMarksHandle = GetNewControl (CNTL_TickMarks, window);
- EmbedControl (self->mTickMarksHandle, self->mScrollBarsHandle);
- SetWindowItemFont (self->mTickMarksHandle, wftb, 6);
- SetControlValue (self->mTickMarksHandle, GetTickMarks (self->mData));
-
- self->mNonDirectionalHandle = GetNewControl (CNTL_NonDirectional, window);
- EmbedControl (self->mNonDirectionalHandle, self->mScrollBarsHandle);
- SetWindowItemFont (self->mNonDirectionalHandle, wftb, 7);
- SetControlValue (self->mNonDirectionalHandle, GetNonDirectional (self->mData));
-
- self->mLittleArrowsHandle = GetNewControl (CNTL_LittleArrows, window);
- EmbedControl (self->mLittleArrowsHandle, self->mScrollBarsHandle);
- SetWindowItemFont (self->mLittleArrowsHandle, wftb, 8);
- SetControlValue (self->mLittleArrowsHandle, GetLittleArrows (self->mData));
-
- self->mSpinnerHandle = GetNewControl (CNTL_Spinner, window);
- EmbedControl (self->mSpinnerHandle, self->mScrollBarsHandle);
- SetWindowItemFont (self->mSpinnerHandle, wftb, 9);
- SetControlValue (self->mSpinnerHandle, GetSpinner (self->mData));
-
- self->mVolumeControlHandle = GetNewControl (CNTL_VolumeControl, window);
- EmbedControl (self->mVolumeControlHandle, self->mScrollBarsHandle);
- SetWindowItemFont (self->mVolumeControlHandle, wftb, 10);
- SetControlValue (self->mVolumeControlHandle, GetVolumeControl (self->mData));
-
- self->mJimSSliderHandle = GetNewControl (CNTL_JimSSlider, window);
- EmbedControl (self->mJimSSliderHandle, self->mScrollBarsHandle);
- SetWindowItemFont (self->mJimSSliderHandle, wftb, 11);
- SetControlValue (self->mJimSSliderHandle, GetJimSSlider (self->mData));
-
- self->mProgressBarsHandle = GetNewControl (CNTL_ProgressBars, window);
- EmbedControl (self->mProgressBarsHandle, self->mBarsHandle);
- SetWindowItemFont (self->mProgressBarsHandle, wftb, 12);
-
- self->mStandard5Handle = GetNewControl (CNTL_Standard5, window);
- EmbedControl (self->mStandard5Handle, self->mProgressBarsHandle);
- SetWindowItemFont (self->mStandard5Handle, wftb, 13);
- SetControlValue (self->mStandard5Handle, GetStandard3 (self->mData));
-
- self->mIndeterminateHandle = GetNewControl (CNTL_Indeterminate, window);
- EmbedControl (self->mIndeterminateHandle, self->mProgressBarsHandle);
- SetWindowItemFont (self->mIndeterminateHandle, wftb, 14);
- SetControlValue (self->mIndeterminateHandle, GetIndeterminate (self->mData));
- SetIndeterminateState (self->mIndeterminateHandle, true);
-
- self->mChasingArrowsHandle = GetNewControl (CNTL_ChasingArrows, window);
- EmbedControl (self->mChasingArrowsHandle, self->mProgressBarsHandle);
- SetWindowItemFont (self->mChasingArrowsHandle, wftb, 15);
- SetControlValue (self->mChasingArrowsHandle, GetChasingArrows (self->mData));
-
- self->mRectangleHandle = GetNewControl (CNTL_Rectangle, window);
- EmbedControl (self->mRectangleHandle, self->mProgressBarsHandle);
- SetWindowItemFont (self->mRectangleHandle, wftb, 16);
- SetControlValue (self->mRectangleHandle, GetRectangle (self->mData));
-
- self->mRoundRectHandle = GetNewControl (CNTL_RoundRect, window);
- EmbedControl (self->mRoundRectHandle, self->mProgressBarsHandle);
- SetWindowItemFont (self->mRoundRectHandle, wftb, 17);
- SetControlValue (self->mRoundRectHandle, GetRoundRect (self->mData));
-
- self->mBarberPoleHandle = GetNewControl (CNTL_BarberPole, window);
- EmbedControl (self->mBarberPoleHandle, self->mProgressBarsHandle);
- SetWindowItemFont (self->mBarberPoleHandle, wftb, 18);
- SetControlValue (self->mBarberPoleHandle, GetBarberPole (self->mData));
-
- self->mRoundBarberHandle = GetNewControl (CNTL_RoundBarber, window);
- EmbedControl (self->mRoundBarberHandle, self->mProgressBarsHandle);
- SetWindowItemFont (self->mRoundBarberHandle, wftb, 19);
- SetControlValue (self->mRoundBarberHandle, GetRoundBarber (self->mData));
-
- SetLayerGroupValue (self->mBarsHandle, GetBars (self->mData));
-
- AdvanceKeyboardFocus (window);
-
- ShowWindow (window);
- }
-
- /*----------*/
- void Bars_Close (
- Bars* self)
- {
- RemoveResponder ((AMSignaler*) self->mData, (AMResponder*) self);
-
- ((EverythingDoc*)self->super.mDoc)->mBarsPtr = nil;
- SetInfo (nil);
- HideWindow (self->super.mWindow);
- DisposeWindow (self->super.mWindow);
-
- DeleteBars (self);
- }
-
- /*----------*/
- void Bars_Track (
- Bars* self,
- ControlHandle whichControl,
- short whichPart,
- Point where)
- {
- Rect bounds;
- short newValue;
-
- if (whichControl == self->mBarsHandle) {
- if (TrackClick (self->mBarsHandle, where) != 0) {
- SetBars (self->mData, GetControlValue (self->mBarsHandle));
- }
- }
- if (whichControl == self->mStandard4Handle) {
- HandleControlClick (self->mStandard4Handle, where, curEvent.modifiers, nil);
- SetStandard2 (self->mData, GetControlValue (self->mStandard4Handle));
- }
- if (whichControl == self->mGraphic4Handle) {
- HandleControlClick (self->mGraphic4Handle, where, curEvent.modifiers, nil);
- SetGraphic2 (self->mData, GetControlValue (self->mGraphic4Handle));
- }
- if (whichControl == self->mSliderHandle) {
- HandleControlClick (self->mSliderHandle, where, curEvent.modifiers, nil);
- SetSlider (self->mData, GetControlValue (self->mSliderHandle));
- }
- if (whichControl == self->mTickMarksHandle) {
- HandleControlClick (self->mTickMarksHandle, where, curEvent.modifiers, nil);
- SetTickMarks (self->mData, GetControlValue (self->mTickMarksHandle));
- }
- if (whichControl == self->mNonDirectionalHandle) {
- HandleControlClick (self->mNonDirectionalHandle, where, curEvent.modifiers, nil);
- SetNonDirectional (self->mData, GetControlValue (self->mNonDirectionalHandle));
- }
- if (whichControl == self->mLittleArrowsHandle) {
- HandleControlClick (self->mLittleArrowsHandle, where, curEvent.modifiers, nil);
- SetLittleArrows (self->mData, GetControlValue (self->mLittleArrowsHandle));
- }
- if (whichControl == self->mSpinnerHandle) {
- HandleControlClick (self->mSpinnerHandle, where, curEvent.modifiers, nil);
- SetSpinner (self->mData, GetControlValue (self->mSpinnerHandle));
- }
- if (whichControl == self->mVolumeControlHandle) {
- HandleControlClick (self->mVolumeControlHandle, where, curEvent.modifiers, nil);
- SetVolumeControl (self->mData, GetControlValue (self->mVolumeControlHandle));
- }
- if (whichControl == self->mJimSSliderHandle) {
- HandleControlClick (self->mJimSSliderHandle, where, curEvent.modifiers, nil);
- SetJimSSlider (self->mData, GetControlValue (self->mJimSSliderHandle));
- }
- }
-
- //----------
- void Bars_DataChanged (
- Bars* self,
- long inDataID)
- {
- if (inDataID == idBars) {
- SetControlValue (self->mBarsHandle, GetBars (self->mData));
- SetLayerGroupValue (self->mBarsHandle, GetBars (self->mData));
- }
- if (inDataID == idStandard2) {
- SetControlValue (self->mStandard4Handle, GetStandard2 (self->mData));
- }
- if (inDataID == idGraphic2) {
- SetControlValue (self->mGraphic4Handle, GetGraphic2 (self->mData));
- }
- if (inDataID == idSlider) {
- SetControlValue (self->mSliderHandle, GetSlider (self->mData));
- }
- if (inDataID == idTickMarks) {
- SetControlValue (self->mTickMarksHandle, GetTickMarks (self->mData));
- }
- if (inDataID == idNonDirectional) {
- SetControlValue (self->mNonDirectionalHandle, GetNonDirectional (self->mData));
- }
- if (inDataID == idLittleArrows) {
- SetControlValue (self->mLittleArrowsHandle, GetLittleArrows (self->mData));
- }
- if (inDataID == idSpinner) {
- SetControlValue (self->mSpinnerHandle, GetSpinner (self->mData));
- }
- if (inDataID == idVolumeControl) {
- SetControlValue (self->mVolumeControlHandle, GetVolumeControl (self->mData));
- }
- if (inDataID == idJimSSlider) {
- SetControlValue (self->mJimSSliderHandle, GetJimSSlider (self->mData));
- }
- if (inDataID == idStandard3) {
- SetControlValue (self->mStandard5Handle, GetStandard3 (self->mData));
- }
- if (inDataID == idIndeterminate) {
- SetControlValue (self->mIndeterminateHandle, GetIndeterminate (self->mData));
- }
- if (inDataID == idChasingArrows) {
- SetControlValue (self->mChasingArrowsHandle, GetChasingArrows (self->mData));
- }
- if (inDataID == idRectangle) {
- SetControlValue (self->mRectangleHandle, GetRectangle (self->mData));
- }
- if (inDataID == idRoundRect) {
- SetControlValue (self->mRoundRectHandle, GetRoundRect (self->mData));
- }
- if (inDataID == idBarberPole) {
- SetControlValue (self->mBarberPoleHandle, GetBarberPole (self->mData));
- }
- if (inDataID == idRoundBarber) {
- SetControlValue (self->mRoundBarberHandle, GetRoundBarber (self->mData));
- }
- }
-
- /*----------*/
- void Bars_MouseIn (
- Bars* self,
- Point where,
- short modifiers)
- {
- Rect bounds;
-
- }
-
- //----------
- void Bars_ExitCurField (
- Bars* self)
- {
- ControlHandle focus;
-
- GetKeyboardFocus (self->super.mWindow, &focus);
-
- if (focus == nil) {
- // nothing to exit
-
- }
- }
-
- /*----------*/
- void Bars_TypeIn (
- Bars* self,
- char ch)
- {
- ControlHandle focus;
- short keyCode;
-
- GetKeyboardFocus (self->super.mWindow, &focus);
-
- if ((ch == charEnter)
- || (ch == charReturn)) {
- Bars_ExitCurField (self); // Dispatch
- } else if (ch == charEsc) {
- } else if (ch == charTab) {
- AMWindow_DoTab ((AMWindow*) self, (curEvent.modifiers & optionKey) != 0);
- } else if (focus != nil) {
- keyCode = curEvent.message & keyCodeMask;
- HandleControlKey (focus, keyCode, ch, curEvent.modifiers);
- AMEngine_SetDirty (self->super.mDoc->mEngine);
- } else {
- SysBeep (1);
- }
- }
-
- /*----------*/
- void Bars_Resize (
- Bars* self)
- {
- /* application-specific code to resize items in window */
- }
-
- /*----------*/
- void Bars_Scroll (
- Bars* self,
- short newValue,
- short oldValue)
- {
- /* application-specific code to scroll window */
- if (gWhichScroll == self->super.vScroll) {
- } else { // horizontal
- }
- }
-
- //----------
- void DoUndo (
- Bars* self)
- {
- } // DoUndo
-
- //----------
- void DoCut (
- Bars* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TECut (curTE);
- AMEngine_SetDirty (self->super.mDoc->mEngine);
- scrapDirty = true;
- }
- } // DoCut
-
- //----------
- void DoCopy (
- Bars* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TECopy (curTE);
- scrapDirty = true;
- }
- } // DoCopy
-
- //----------
- void DoPaste (
- Bars* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TEPaste (curTE);
- AMEngine_SetDirty (self->super.mDoc->mEngine);
- }
- } // DoPaste
-
- //----------
- void DoClear (
- Bars* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TEDelete (curTE);
- AMEngine_SetDirty (self->super.mDoc->mEngine);
- }
- } // DoClear
-
- //----------
- void DoSelectAll (
- Bars* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TESetSelect (0, 32767, curTE);
- }
- } // DoSelectAll
-
- //----------
- void DoShowClipboard (
- Bars* self)
- {
- } // DoShowClipboard
-
- //----------
- Boolean Bars_DoCommand (
- Bars* self,
- long inCommand)
- {
- Boolean result = true;
-
- switch (inCommand) {
- case cmdUndo:
- DoUndo (self);
- break;
- case cmdCut:
- DoCut (self);
- break;
- case cmdCopy:
- DoCopy (self);
- break;
- case cmdPaste:
- DoPaste (self);
- break;
- case cmdClear:
- DoClear (self);
- break;
- case cmdSelectAll:
- DoSelectAll (self);
- break;
- case cmdShowClipboard:
- DoShowClipboard (self);
- break;
-
- default:
- result = false;
- } // switch
-
- return result;
- }
-